N=int(input())
a=[0 for i in range(0,N)]
T=0
D=0
E=0

for i in range(0,N):
    nums=list(map(int,input().split()))
    now=nums[1]
    for j in range(2,nums[0]+1):
        if nums[j]<=0:
            now+=nums[j]
        else:
            if now>nums[j]:
                a[i]=1
                now=nums[j]
    T+=now
    D+=a[i]

for i in range(0,N-2):
    if sum(a[i:i+3])==3:
        E+=1

if a[0]+a[-1]+a[-2]==3:
    E+=1
if a[0]+a[1]+a[-1]==3:
    E+=1

print(T,D,E)